package com.sfpay.coreplatform.order.service.composite.impl;

import org.springframework.stereotype.Service;

import com.sfpay.coreplatform.order.common.OrderResponseCode;
import com.sfpay.coreplatform.order.service.composite.IHandler;
import com.sfpay.coreplatform.order.service.composite.common.PayContext;
import com.sfpay.coreplatform.order.service.validate.ValidateNULL;
import com.sfpay.coreplatform.order.valueobject.dto.PayRequest;
import com.sfpay.coreplatform.order.valueobject.dto.Response;
@Service
public class CheckParamHandler implements IHandler {

	@Override
	public Response Handler(PayRequest request, PayContext payContext) {
		Response response = new Response();
		response.setReturnCode(OrderResponseCode.ORDER_RESPONSE_PARAM_ISNULL);

		if (request == null) {

			response.setReturnMsg("method:checkParamNullHandel request is NULL ");
			return response;
		}

		if (ValidateNULL.checkStringNull(request.getOutTradeNo())) {
			response.setReturnMsg("method:checkParamNullHandel outTradeno is NULL");
			return response;
		}
		if (ValidateNULL.checkLongNull(request.getPayerAcctNo())) {
			response.setReturnMsg("method:checkParamNullHandel payerAcctNo is NULL");
			return response;
		}
		if (request.isAccPasword()
				&& ValidateNULL.checkStringNull(request.getPayerPassword())) {
			response.setReturnMsg("method:checkParamNullHandel payerpassword is NULL");
			return response;
		}
		if (ValidateNULL.checkLongNull(request.getPayeeAcctNo())) {
			response.setReturnMsg("method:checkParamNullHandel payeeacctno is NULL");
			return response;
		}
		if (ValidateNULL.checkLongNull(request.getPayAmt())) {
			response.setReturnMsg("method:checkParamNullHandel payamt is 0 ");
			return response;
		}
		if (ValidateNULL.checkLongNull(request.getPlatformMemberNo())) {
			response.setReturnMsg("method:checkParamNullHandel platformMemberNo is NULL");
			return response;
		}
		if (ValidateNULL.checkStringNull(request.getTradePostNo())) {
			response.setReturnMsg("method:checkParamNullHandel tradePostNo is NULL");
			return response;
		}
		if (ValidateNULL.checkStringNull(request.getPayPostNo())) {

			response.setReturnMsg("method:checkParamNullHandel payPostNo is NULL");
			return response;
		}

		response.setReturnCode(OrderResponseCode.ORDER_RESPONSE_SUCESS);

		return response;
	}

	@Override
	public String getHandlerName() {
		 
		return "CheckParamHandler";
	}

}
